package view

import (
	"cloudops/src/common"
	"cloudops/src/models"
	"fmt"
	"github.com/gin-gonic/gin"
	"go.uber.org/zap"
)

type CommonSelectResponse struct {
	Label string `json:"label"`
	Value string `json:"value"`
}

type BatchSwitchReqest struct {
	Ids []int `json:"ids"`
}

// 公共方法传入username 给当前用户
func commonGetUsersByNames(userNames []string, logger *zap.Logger, c *gin.Context) (res []*models.User) {
	//转换
	for _, userName := range userNames {
		userName := userName
		dbUser, err := models.GetUserByUserName(userName)
		if err != nil {
			logger.Error("查询用户失败", zap.Error(err))
			common.ReqBadFailWithMessage(fmt.Sprintf("查询用户失败", err.Error()), c)
			return
		}
		res = append(res, dbUser)
	}
	return
}
